<?php
require_once 'Response.php';
require_once 'DB.php';

$user = (array)json_decode(file_get_contents( "php://input"));

//2. 存入数据库
$sql = "INSERT `comment` (content, shand_id, user_name) VALUES ('".$user['content']."', {$user['shand_id']}, '".$user['user_name']."')";
$pdo = DB::getInstance()->connect();
$count  =  $pdo->exec($sql); //返回受影响的行数

//3. 结果返回
Response::json(200, '添加成功！', ['id'=>$pdo->lastInsertId()]);